home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  2.1 KB  |  114 lines

  1. /*
  2.  * main initialization routines for GENIAL
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "display.h"
  8. #include "ui.h"
  9. #include "sm.h"
  10.  
  11.  
  12. char     *in_image = NULL;
  13.  
  14. main(argc, argv)
  15.     int       argc;
  16.     char     *argv[];
  17. {
  18.     void      parse_args();
  19.  
  20.     Progname = strsave(*argv);
  21.     hipserrlev = HEL_SEVERE;    /* only exit if severe errors */
  22.     hipserrprt = HEL_ERROR;    /* print messages for hips errors */
  23.  
  24.     parse_args(argc, argv);
  25.  
  26.     /*
  27.      * Initialize XView.
  28.      */
  29.     xv_init(XV_INIT_ARGS, argc, argv, NULL);
  30.  
  31.     /* initialize user interface */
  32.     init_ui();
  33.  
  34.     /* initialize the colormap */
  35.     cmap_init();
  36.  
  37.     /* initialize state machine */
  38.     init_sm();
  39.  
  40.     /* initialize log */
  41.     init_log();
  42.  
  43.     /* lets start... */
  44.     rdom_linear();
  45.  
  46.     /* load file if given as command line arguement */
  47.     if (in_image != NULL) {
  48.     if (load_image(in_image) == 1) {
  49.         fxn_init();
  50.         new_state(IMG_LOADED);
  51.     }
  52.     }
  53.     xv_main_loop(base_win->ctrlwin);
  54.     exit(0);
  55. }
  56.  
  57. /***********************************************************/
  58. shutdown()
  59. {
  60.  
  61. #ifdef DEBUG
  62.     printf("shutting down\n");
  63. #endif
  64.  
  65.     exit(0);
  66. }
  67.  
  68. /***********************************************************/
  69. void
  70. parse_args(argc, argv)
  71.     int       argc;
  72.     char     *argv[];
  73. {
  74.     void      usageterm();
  75.  
  76.     int       verbose = 0;
  77.  
  78.     /* Interpret options  */
  79.     while (--argc > 0 && (*++argv)[0] == '-') {
  80.     char     *s;
  81.     for (s = argv[0] + 1; *s; s++)
  82.         switch (*s) {
  83.         case 'i':
  84.         if (argc < 2)
  85.             usageterm();
  86.         in_image = *++argv;
  87.         fprintf(stderr, " using image file: %s\n", in_image);
  88.         argc--;
  89.         break;
  90.         case 'v':
  91.         verbose++;
  92.         break;
  93.         case 'h':
  94.         usageterm();
  95.         break;
  96.         default:
  97.         usageterm();
  98.         break;
  99.         }
  100.     }
  101. }
  102.  
  103. /******************************************************/
  104. void
  105. usageterm()
  106. {
  107.     fprintf(stderr, "Usage: genial [-i image][-v][-h][-help] \n");
  108.     fprintf(stderr, "        [-i HIPS file] load specified image file \n");
  109.     fprintf(stderr, "        [-v] verbose mode (not yet implemented) \n");
  110.     fprintf(stderr, "        [-h] this list \n");
  111.     fprintf(stderr, "        [-help] list of window attribute help \n\n");
  112.     exit(0);
  113. }
  114.